package com.yf.zzmusic.pojo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 字典表，根据type进行
 * </p>
 *
 * @author
 * @since 2024-02-28
 */
@Getter
@Setter
@TableName("sys_dict_data")
public class SysDictData implements Serializable {

  private static final long serialVersionUID = 1L;

  @TableId(value = "sys_dict_data_id", type = IdType.AUTO)
  private Integer sysDictDataId;

  /**
   * 字典显示名称
   */
  @NotNull(message = "字典名称不可为空")
  private String dictLabel;

  /**
   * 字典值
   */
  @NotNull(message = "字典值不可为空")
  private Integer dictValue;

  /**
   * 字典类型，不同字典根据该字段进行查询
   */
  @NotNull(message = "字典类型不可为空")
  private String dictType;

  /**
   * 字典备注，用于系统中管理员的备注信息
   */
  private String remark;

  /**
   * 创建时间
   */
  @DateTimeFormat(pattern = "yyyy-MM-dd")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private LocalDateTime createTimer;

  public Long getCreateTimer() {
    if (createTimer!=null){
      long timestamp = createTimer.toInstant(ZoneOffset.of("+8")).toEpochMilli();
      return timestamp;
    }else{
      return null;
    }

  }

  public void setCreateTimer(LocalDateTime createTimer) {
    this.createTimer = createTimer;
  }

  /**
   * 是否有默认值，0表示没有，1表示有
   */
  private Integer isDefault;

}
